function jsonp(url,options={}){
    const {params={},jsonp="callback"}= options;// {a:1}
    return new Promise(resolve=>{
        const fnName = "zhang" + Math.random().toString(36).slice(2);
        window[fnName] = function (res) {
            resolve(res);
        }
        params[jsonp] = fnName;// {a:1,callback:xxx}
        // a=1&callback=xxx

        const script = document.createElement("script");
        script.src = url+"?"+Object.keys(params).map(key=>key+"="+params[key]).join("&");
        script.onload = function () {
            delete window[fnName];
            // 当指定的src文件加载完毕后执行
            document.body.removeChild(script);
        }
        document.body.appendChild(script);

    })
}